import java.util.Scanner;

public class Test {

        //出现数字9的数字
        public static void main1(String[] args) {
            int count=0;
            for(int i=1;i<=100;i++){
                if(i%10==9){
                    System.out.println("出现数字9的数字有"+i);
                    count++;
                }

            }
            System.out.println("一共有"+count+"个数");
        }

        //判断素数
        public static void main4(String[] args) {

            while(true){

                Scanner scanner=new Scanner(System.in);
                System.out.print("请输入一个数字：");
                int num=scanner.nextInt();
                int i=2;
                for (i = 2; i <=num ; i++) {
                    if(num%i==0){
                        break;
                    }
                }
                if(i==num)
                    System.out.println(num+"是素数");
                else
                    System.out.println(num+"不是素数");
                i=2;
            }

        }
    //判断素数
    public static void main5(String[] args) { //最大公约数
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.print("请输入第一个数：");
            int num1 = scanner.nextInt();
            System.out.print("请输入第二个数：");
            int num2 = scanner.nextInt();
            int tmp = (num1 > num2) ? num2 : num1;
            for (int i = tmp; i >= 1; i--) {
                if (num1 % i == 0 && num2 % i == 0) {
                    System.out.println("最大公约数是" + i);
                    break;
                }
            }
        }
    }

    //计算1/1-1/2+1/3-1/4+1/5 …… + 1/99 - 1/100 的值
    public static void main6(String[] args) {
        double i=1.0;
        double sum=0;
        int k=1;
        for(int f=1;f<=100;f++)
        {
            sum=1/i*k+sum;
            i++;
            k*=-1;
        }
        System.out.println(sum);
    }

    //打印x图形
    public static void main7(String[] args) {
        while(true) {
            System.out.print("请输入行数：");
            int k=1;
            Scanner scanner = new Scanner(System.in);
            int r=scanner.nextInt();
            for(int i=1;i<=r;i++) {
                for(int l=1;l<=r;l++)
                {
                    if(i==l||l==r-i+1) {
                        System.out.print("*");
                    }
                    else {
                        System.out.print(" ");
                    }

                }
                System.out.print("\n");
            }

        }
    }

    //模拟登陆
    public static void main8(String[] args) {
        int flag = 1;
        String str = "123456";
        while (flag <= 3) {
            System.out.print("请输入您的密码：");
            Scanner scanner = new Scanner(System.in);
            String input = scanner.nextLine();
            if (input.equals(str)) {
                System.out.println("登陆成功");
                break;
            }
            else {
                System.out.println("密码错误，登陆失败，请重新输入");
                flag++;
            }
        }
        if(flag>3)
        {
            System.out.println("退出登录，请联系相关工作人员修改密码");
        }
    }


    //输出9*9乘法表
    public static void main9(String[] args) {
        for (int l = 1; l <=9 ; l++) {
            for (int r = 1; r <=l; r++) {
                System.out.print(r+"*"+l+"="+(l*r)+" ");
            }
            System.out.println("\n");
        }
    }

}

